package fgoScript.exception;

import commons.util.GameUtil;
import fgoScript.constant.GameConstant;
import fgoScript.constant.PointInfo;
import mail.mailUtil;

public class AppNeedUpdateException extends Exception {
	private static final long serialVersionUID = 1877932104145533378L;
	private static long lastThrowMillions= System.currentTimeMillis();
	private static int countError = 0;
	public AppNeedUpdateException() {
		if(++countError % 10 == 0){
			String USERNAME = "zmczmckkk@outlook.com";
			String PASSWORD = "Beauty6499!@#";
			mailUtil.sendSMTPMail(USERNAME,PASSWORD,USERNAME,
					"异常超过"+countError+"次，异常信息如下："+"\n" + this.getMessage(),"主机可能出现循环状态！");
		}
	}
	@Override
	public String getMessage() {
		PointInfo.pointInfo = null;
		if(System.currentTimeMillis()-lastThrowMillions > 5 * 1000){
			GameUtil.fullScreen2file(GameConstant.IMG_EXTEND, GameUtil.getPicLogsPath() + "\\ExceptionPic\\" + "AppNeedUpdateException_" + System.currentTimeMillis() + ".");
		}
		lastThrowMillions=System.currentTimeMillis();
		return "更新FGO，重新执行脚本！";
	}
}
